SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00004 1 08-24-9413:52ALL MIKE COPELAND Is Printer Online ?? SWAG9408 c4╞ƒ 6 ε╡ {π>> I'm using TP6 and plan to use to the PRINTER.TPU unit theπ>> write to the printer. How do you detect whether the printerπ>> is on or not without ending up a dos error and the programπ>> halting.ππ You need to check the status of the printer port. Something likeπthis:π}ππfunction TESTONLINE : Byte; { Tests for Printer On Line }πvar REGS : Registers;πbeginπ with REGS doπ beginπ AH := 2; DX := 0;π Intr($17, Dos.Registers(REGS));π TESTONLINE := AHπ endπend; { TESTONLINE }ππ if TESTONLINE = 144 then okay_to_printπ else printer_not_readyππ 2 08-25-9409:06ALL RANDALL ELTON DING Printing Graphics SWAG9408 ├╜q╔ 44 ε╡ {πFrom: randyd@alpha2.csd.uwm.edu (Randall Elton Ding)ππAll those c/pascal flames are becoming nauseating.πMy kill file leaves me with about 10 articles per day now.πFor people like me ignoring this B.S., here is somethingπfor fun.ππThis very elegantly plots a cycloid in 3d with hidden lines.πRemember that a cycloid is what you get when you trace a singleπpoint of a circle in rolling motion.ππEmail me if you would like the normal cartesian plotter.ππ------------------------------------------------------------------ππ(* Three Dimensional Plotter (modified for this parametric equ.)π written by Randy Dingπ randyd@alpha2.csd.uwm.eduπ original December 1983 (UCSD pascal)π update April 13,1991 (turbo pascal) *)π}π{$N+}πprogram plotter;ππuses graph;πππconstπ bgipath = 'e:\bp\bgi'; { !set this to your bgi directory }πππconstπ displaysizex= 9.75; { inches, for width/height ratios }π displaysizey= 7; { inches }π maxrightscreen= 999; { !make this bigger if you have incredible graphics }ππtypeπ realtype= single;π scrnarry= array [0..maxrightscreen] of integer; { for hidden line data }ππvarπ toplim,botlim,previousx,botscreen,rightscreen: integer;π colr: word;π top,bot: scrnarry;π alpha,beta,scale,centerx,centery,posx,negx,posy,negy,stepx,stepy: realtype;πππprocedure hideline (x,y,x2,y2: integer);π var slope,yr: realtype;ππ procedure vline (ytop,ybot: integer); { at x with colr }π var temp: integer;ππ beginπ if (x>=0) and (x<=rightscreen) then beginπ if ytop > ybot then beginπ temp:= ytop; ytop:= ybot; ybot:= temp;π end;π if x <> previousx then beginπ toplim:= top [x];π botlim:= bot [x];π end;π if ytop < top [x] then top [x]:= ytop;π if ybot > bot [x] then bot [x]:= ybot;π while ytop <= ybot do beginπ if (ytop < toplim) or (ytop > botlim) then putpixel (x,ytop,colr);π ytop:= ytop+1;π end;π end;π previousx:= x;π end;ππ beginπ yr:= y;π if x <> x2 then beginπ slope:= (y2-y)/(x2-x);π while x <> x2 do beginπ yr:= yr+slope;π vline (y,trunc(yr));π y:= trunc(yr);π if x < x2 then inc(x) else dec(x);π end;π end;π vline (y,y2);π end;πππprocedure initline;π var x:integer;ππ beginπ for x:= 0 to rightscreen do beginπ top [x]:= botscreen+1;π bot [x]:= -1;π end;π end;πππ{ The regular cartesian plot routine has been modified to plot thisπ parametric equation and a slope counter has been added to make theπ plotting slow down near the points, helping to make them crisp.π The cycloid parametric function: x=u-sin(u), y=cos(u) }ππprocedure plot;π varπ correction,sa,ca,sb,cb,x,y,z,rho,lou,hiu,du,u,dy,oldz: realtype;π oldx,oldy,screenx,screeny,slopecounter: integer;π newline: boolean;π ch: char;ππ beginπ correction:= scale*(displaysizey/(botscreen+1))π /(displaysizex/(rightscreen+1));π sa:= sin(alpha*pi/180);π ca:= cos(alpha*pi/180);π sb:= sin(beta*pi/180);π cb:= cos(beta*pi/180);π previousx:= -1;π x:= posx;π while x >= negx do beginπ newline:= true;π y:= negy;π while y <= posy do beginπ rho:= sqrt(sqr(x)+sqr(y));π lou:= rho-1;π hiu:= rho+1;π repeat { solve the parametric equation by iteration }π u:= (lou+hiu)/2;π du:= rho-(u-sin(u)); { u-sin(u) is an increasing function }π if du>0 then lou:= u else hiu:= u;π until abs(du) < 0.001;π z:= 3*cos(u); { user parametric function x=u-sin(u), y=cos(u) }π screenx:= trunc ((y*ca-x*sa)*correction+centerx);π screeny:= trunc (centery-((y*sa+x*ca)*sb+z*cb)*scale);π if newline then beginπ slopecounter:= 0;π dy:= stepy; { make dy normal for long straight runs }π endπ else if (z-oldz)/dy > 1.5 then beginπ slopecounter:= 5;π dy:= stepy/10; { make dy small close to the peaks }π endπ else if slopecounter=0 then dy:= stepy else dec(slopecounter);π y:= y + dy;π oldz:= z;π if not newline then hideline(oldx,oldy,screenx,screeny)π else newline:= false;π oldx:= screenx;π oldy:= screeny;π end;π x:= x - stepx;π end;π end;πππprocedure setdefault;π { with no rotation, x axis is out of the screen, y axis is to the rightπ and z axis is up; alpha and beta make the figure rotateπ (pos is clockwise) within the fixed coordinate axisπ draw figure from screen front to back for hidden lines to work properly }ππ beginπ alpha:= 30; { rotates figure clockwise about z axis }π beta:= -40; { rotates figure clockwise about y axis }π scale:= 10;π centerx:= (rightscreen+1)/2;π centery:= (botscreen+1)/2;π posx:= 20; { currently set up for functions z of x,y }π negx:= -posx; { change user function z above in plot procedure }π posy:= 20;π negy:= -posy;π stepx:= 0.5;π stepy:= 0.1;π colr:= white;π end;πππprocedure initbgi;π var errcode,grmode,grdriver: integer;π beginπ grdriver:= detect;π grmode:= 0;π initgraph (grdriver,grmode,bgipath);π errcode:= graphresult;π if errcode <> grok then beginπ writeln ('Graphics error: ',grapherrormsg (errcode));π halt (1);π end;π end;πππbeginπ initbgi;π botscreen:= getmaxy;π rightscreen:= getmaxx;π initline;π setdefault;π plot;π readln;π closegraph;πend.ππ 3 08-25-9409:09ALL MARTIN PREISHUBER Postscript File ManipulatSWAG9408 e7` 63 ε╡ {ππDate: 07-03-94 (04:34) Number: 131410 of 132082 (Refer# NONE)π To: KERRY SOKALSKYπFrom: MARTIN_P@EFN.EFN.ORGπSubj: Re: SWAGπRead: 07-04-94 (01:01) Status: RECEIVER ONLYπConf: Internet_Mail (104) Read Type: READING ALL (+)ππFrom: Martin Preishuber <martin_p@efn.efn.org>ππpostscrp.pas unit, to create postscript files.. it includes theπ common commands like line, outtext and so onπpsdemo.pas demo program for postscrp.pas. i made it to show, howπ to use the PSSetViewPort and PSOpen-commands.ππ}ππPROGRAM PSDemo;ππUSES Postscrp;ππBEGINπ PSSetViewPort(0, 0, 21, 29.7);π PSOpen('test.ps', 0, 479, 639, 479);π PSTextSettings('Times-Roman', 40);π PSOutTextXY(100, 100, 'Test');π PSClose;πEND.πππUNIT PostScrp;ππINTERFACEππUSES Dos, Graph;ππTYPE Viereck = ARRAY[1..4] OF PointType;π Polygon = ARRAY[1..100] OF PointType;ππPROCEDURE PSSetViewPort(x1, y1, x2, y2 : REAL);πPROCEDURE PSSetGray(intensity : REAL);πPROCEDURE PSSetCmykColor(cyan, magenta, yellow, black : REAL);πPROCEDURE PSSetRGBColor(rot, gruen, blau : REAL);πPROCEDURE PSSetHsbColor(hue, saturation, brightness : REAL);πPROCEDURE PSTextSettings(font : STRING; groesse : WORD);πPROCEDURE PSTextAngle(angle : REAL);πPROCEDURE PSOuttextxy(x, y : REAL; s : STRING);πPROCEDURE PSWriteNum(x, y, num : REAL);πPROCEDURE PSCircle(x, y, radius : REAL);πPROCEDURE PSLineWidth(x : REAL);πPROCEDURE PSLine(x1, y1, x2, y2 : REAL);πPROCEDURE PSRectangle(x1, y1, x2, y2 : REAL);πPROCEDURE PSMoveTo(x, y : REAL);πPROCEDURE PSLineTo(x, y : REAL);πPROCEDURE PSBar(x1, y1, x2, y2 : REAL);πPROCEDURE PsFillViereck(VAR points : Viereck);πPROCEDURE PSFillPoly(anzahl : BYTE; VAR PolyPoints : Polygon);πPROCEDURE PSOpen(filename : STRING; ursprx, urspry, maxx, maxy : WORD);πPROCEDURE PSClose;πFUNCTION PSError : BOOLEAN;πFUNCTION PixelToZoll(x : REAL) : WORD;ππIMPLEMENTATIONππCONST einheit = 2.54/72;π faktor = 3/140;ππVAR psfile : Text;π error : BOOLEAN;π dx, dy,π ux1, uy1,π xdim, ydim,π diffx, diffy : REAL;π newviewport : BOOLEAN;ππFUNCTION PSError : BOOLEAN;πBEGINπ PSError := error;πEND;ππPROCEDURE PSSetViewPort(x1, y1, x2, y2 : REAL);πVAR breite,hoehe : REAL;πBEGINπ breite := x2 - x1;π IF breite <= 0 THEN breite := 15;π hoehe := y2 - y1;π IF hoehe <= 0 THEN hoehe := 15;π ux1 := x1 / einheit;π uy1 := y1 / einheit;π xdim := breite / einheit;π ydim := hoehe / einheit;π newviewport := TRUE;πEND;ππPROCEDURE PSSetGray(intensity : REAL);πBEGINπ WriteLn(psfile, intensity:4:2, ' sg');πEND;ππPROCEDURE PSSetRGBColor(rot, gruen, blau : REAL);πBEGINπ WriteLn(psfile, rot:4:2, ' ', gruen:4:2, ' ', blau:4:2, ' sr');πEND;ππPROCEDURE PSSetCmykColor(cyan, magenta, yellow, black : REAL);πBEGINπ WriteLn(psfile,cyan:4:2, ' ', magenta:4:2, ' ', yellow:4:2, ' ', black:4:2,'πsc');πEND;ππPROCEDURE PSSetHsbColor(hue, saturation, brightness : REAL);πBEGINπ WriteLn(psfile, hue:4:2, ' ', saturation:4:2, ' ', brightness:4:2, ' sh');πEND;ππFUNCTION PixelToZoll(x : REAL) : WORD;πBEGINπ PixelToZoll := Round(x * dx);πEND;ππPROCEDURE PSTextSettings(font : STRING; groesse : WORD);πBEGINπ WriteLn(psfile, '/', font, ' findfont ',groesse,' scalefont setfont');πEND;ππPROCEDURE PSTextAngle(angle : REAL);πBEGINπ WriteLn(psfile, angle:4:2,' rotate');πEND;ππPROCEDURE PSOuttextxy(x,y : REAL; s : STRING);πBEGINπ x := x - diffx;π y := diffy - y;π WriteLn(psfile, x * dx:4:2, ' ', y * dy:4:2, ' m');π WriteLn(psfile, '(',s,')', ' show');πEND;ππPROCEDURE PSWriteNum(x, y, num : REAL);πVAR help : STRING;πBEGINπ x := x - diffx;π y := diffy - y;π Str(num:4:2, help);π WriteLn(psfile, x * dx:4:2, ' ', y * dy:4:2, ' m');π WriteLn(psfile, '(',help,')', ' show');πEND;ππPROCEDURE PSCircle(x, y, radius : REAL);πBEGINπ x := x - diffx;π y := diffy - y;π WriteLn(psfile, x * dx:4:2, ' ', y * dy:4:2, ' ', radius:4:2, ' 0 360 arcπs');πEND;ππPROCEDURE PSLineWidth(x : REAL);πBEGINπ WriteLn(psfile, x:4:2, ' setlinewidth');πEND;ππPROCEDURE PSLine(x1, y1, x2, y2 : REAL);πBEGINπ x1 := x1 - diffx;π y1 := diffy - y1;π x2 := x2 - diffx;π y2 := diffy - y2;π WriteLn(psfile, x1 * dx:4:2, ' ', y1 * dy:4:2, ' m');π WriteLn(psfile, x2 * dx:4:2, ' ', y2 * dy:4:2, ' l s');πEND;ππPROCEDURE PSRectangle(x1, y1, x2, y2 : REAL);πVAR xn1, xn2, yn1, yn2 : REAL;πBEGINπ x1 := x1 - diffx;π y1 := diffy - y1;π x2 := x2 - diffx;π y2 := diffy - y2;π xn1 := x1 * dx;π yn1 := y1 * dy;π xn2 := x2 * dx;π yn2 := y2 * dy;π WriteLn(psfile, 'n');π WriteLn(psfile, xn1:4:2, ' ', yn1:4:2, ' m');π WriteLn(psfile, xn2:4:2, ' ', yn1:4:2, ' l');π WriteLn(psfile, xn2:4:2, ' ', yn2:4:2, ' l');π WriteLn(psfile, xn1:4:2, ' ', yn2:4:2, ' l');π WriteLn(psfile, 'c s');πEND;ππPROCEDURE PSMoveTo(x, y : REAL);πBEGINπ x := x - diffx;π y := diffy - y;π WriteLn(psfile, x * dx:4:2, ' ', y * dy:4:2, ' m');πEND;ππPROCEDURE PSLineTo(x, y : REAL);πBEGINπ x := x - diffx;π y := diffy - y;π WriteLn(psfile, x * dx:4:2, ' ', y * dy:4:2, ' l');πEND;ππPROCEDURE PSBar(x1, y1, x2, y2 : REAL);πVAR xn1, xn2, yn1, yn2 : REAL;πBEGINπ x1 := x1 - diffx;π y1 := diffy - y1;π x2 := x2 - diffx;π y2 := diffy - y2;π xn1 := x1 * dx;π yn1 := y1 * dy;π xn2 := x2 * dx;π yn2 := y2 * dy;π WriteLn(psfile, 'n');π WriteLn(psfile, xn1:4:2, ' ', yn1:4:2, ' m');π WriteLn(psfile, xn2:4:2, ' ', yn1:4:2, ' l');π WriteLn(psfile, xn2:4:2, ' ', yn2:4:2, ' l');π WriteLn(psfile, xn1:4:2, ' ', yn2:4:2, ' l');π WriteLn(psfile, 'c');π WriteLn(psfile, 'f');πEND;ππPROCEDURE PsFillViereck(VAR points : Viereck);πBEGINπ WriteLn(psfile, 'n');π WriteLn(psfile, (points[1].x - diffx) * dx:4:2, ' ', (diffy - points[1].y) *πdy:4:2, ' m');π WriteLn(psfile, (points[2].x - diffx) * dx:4:2, ' ', (diffy - points[2].y) *πdy:4:2, ' l');π WriteLn(psfile, (points[3].x - diffx) * dx:4:2, ' ', (diffy - points[3].y) *πdy:4:2, ' l');π WriteLn(psfile, (points[4].x - diffx) * dx:4:2, ' ', (diffy - points[4].y) *πdy:4:2, ' l');π WriteLn(psfile, 'c');π WriteLn(psfile, 'f');πEND;ππPROCEDURE PSFillPoly(anzahl : BYTE; VAR PolyPoints : Polygon);πVAR i : BYTE;πBEGINπ IF anzahl = 1 THENπ ELSEπ IF anzahl=2 THENπ PSLine(PolyPoints[1].x, PolyPoints[1].y, PolyPoints[2].x,πPolyPoints[2].y)π ELSEπ BEGINπ WriteLn(psfile, 'n');π WriteLn(psfile, (PolyPoints[1].x - diffx) * dx:4:2, ' ', (diffy -πPolyPoints[1].y) * dy:4:2, ' m');π FOR i := 2 TO anzahl DOπ WriteLn(psfile, (PolyPoints[i].x - diffx) * dx:4:2, ' ', (diffy -πPolyPoints[i].y) * dy:4:2, ' l');π WriteLn(psfile, 'c');π WriteLn(psfile, 'f');π END;πEND;ππPROCEDURE PSOpen(filename : STRING; ursprx, urspry, maxx, maxy : WORD);πBEGINπ error:=FALSE;π Assign(psfile,filename);π {$I-}π Rewrite(psfile);π {$I+}π IF IOResult<>0 THENπ error:=FALSEπ ELSEπ BEGINπ diffx:=ursprx;π diffy:=urspry;π IF newviewport THENπ BEGINπ WriteLn(psfile,'%!PS-Adobe-2.0');π WriteLn(psfile,'/l',' ','{ lineto } def');π WriteLn(psfile,'/li',' ','{ line } def');π WriteLn(psfile,'/m',' ','{ moveto } def');π WriteLn(psfile,'/f',' ','{ fill } def');π WriteLn(psfile,'/n',' ','{ newpath } def');π WriteLn(psfile,'/c',' ','{ closepath } def');π WriteLn(psfile,'/s',' ','{ stroke } def');π WriteLn(psfile,'/sr',' ','{ setrgbcolor } def');π WriteLn(psfile,'/sh',' ','{ sethsbcolor } def');π WriteLn(psfile,'/sc',' ','{ setcmykcolor } def');π WriteLn(psfile,'/sg',' ','{ setgray } def');π WriteLn(psfile,ux1:4:2,' ',uy1:4:2,' ','translate');π dx:=xdim/maxx;π dy:=ydim/maxy;π ENDπ ELSEπ BEGINπ dx:=800/maxx;π dy:=750/maxy;π END;π WriteLn(psfile,'n');π END;πEND;ππPROCEDURE PSClose;πBEGINπ WriteLn(psfile,'showpage');π {$I-}π Close(psfile);π {$I+}π IF IOResult<>0 THEN error:=TRUE;πEND;ππBEGINπ newviewport:=FALSE;πEND.ππ 4 08-25-9409:10ALL RANDALL ELTON DING Printing Graphics SWAG9408 -╝∞╝ 36 ε╡ {πFrom: randyd@alpha2.csd.uwm.edu (Randall Elton Ding)ππ>How do you get an Epson-compatible 24-pin printer to print graphics?π>Printing text is simple... just open the appropriate LPT port andπ>redirect text into it.π>π>I suppose if I had a manual for the printer I could find out what any ofπ>the escape codes are.ππHere is a routine I wrote years agoπfor my old Epson MX-100 (made in early 80's)πYou should get some ideas from this program, it may even be capableπof being modified to work with your printer.πI don't know if the escape codes are the same, you'll have toπlook them up. BTW, this printer is a 9 pin and only 8 are used.πThats convenient because each print head pass generates 8 pixils highπper character sent. I don't know how your 24 pin works.π}ππprogram develop; { developed for Epson MX-100 and EGA screen }ππuses graph;ππconstπ rotate90= true;π widepaper= false;π bgipath: string = 'e:\bp\bgi';πππprocedure initbgi;π varπ errcode,grdriver,grmode: integer;ππ beginπ grdriver := Detect;π initgraph(grdriver,grmode,bgipath);π errcode:= graphresult;π if errcode <> grok then beginπ writeln('Graphics error: ',grapherrormsg (errcode));π halt(1);π end;π end;ππππprocedure developgraph(rotate: boolean);π { if passed parameter is true, the graphicsπ image will be rotated 90 degrees to fit onπ a narrow sheet of printer paper, if falseπ the image will completely fill the wideπ paper erect and double height }ππ const maxprinter = 816; { maximum width of printer }ππ varπ graphwidth,graphheight,printerwidth,printerheight: integer;π n1,n2,sx,sy,x,y,y2,pixcolr: integer;π widthratio,heightratio: real;π blank: boolean;π bitloc,bits: byte;π bytes: array [1..maxprinter] of byte;π lst: text;ππ beginπ assign(lst,'lpt1');π rewrite(lst);π case rotate ofπ widepaper: begin { develop erect on wide paper }π graphwidth:= getmaxx+1;π graphheight:= getmaxy+1;π printerwidth:= maxprinter; { scale 1.275 x 2 }π printerheight:= graphheight*2;π end;π rotate90: begin { if rotate then reverse x and y }π graphwidth:= getmaxy+1;π graphheight:= getmaxx+1;π printerwidth:= graphwidth; { scale 1 x 1 }π printerheight:= graphheight;π end;π end;π n2:= printerwidth div 256;π n1:= printerwidth mod 256;π write(lst,chr(27),'A',chr(8)); { set line spacing to 8 }π widthratio:= printerwidth/graphwidth;π heightratio:= printerheight/graphheight;π y:= 0;π while y < printerheight do beginπ blank:= true; { remains true if entire printer pass is blank }π for x:= 1 to printerwidth do beginπ sx:= trunc((x-1)/widthratio); { screen x coorid }π bits:= 0;π bitloc:= $80;π for y2:= y to y+7 do beginπ sy:= trunc(y2/heightratio); { screen y coorid }π if sy < graphheight then begin { last printer pass is incomplete }π case rotate ofπ widepaper: pixcolr:= getpixel(sx,sy);π rotate90: pixcolr:= getpixel(sy,sx); { x and y swaped }π end;π if pixcolr > 0 then bits:= bits or bitloc;π end;π bitloc:= bitloc shr 1;π end;π case rotate ofπ widepaper: bytes[x]:= bits;π rotate90: bytes[printerwidth-x+1]:= bits; { reverse image }π end;π if bits > 0 then blank:= false; { have something to print this pass }π end;π if not blank then begin { line feed if nothing to print this pass }π write (lst,chr(27),'K',chr(n1),chr(n2)); { set printer graph mode }π for x:= 1 to printerwidth do write (lst,chr(bytes[x]));π end;π writeln(lst); { output 8 printer pixels high per pass }π y:= y+8;π end;π write(lst,chr(12)); { top of form }π write(lst,chr(27),'@'); { re-initalize printer }π close(lst);π end;πππbeginπ initbgi;ππ { your graphics code here }π Line(100,100,200,100);π Line(200,100,200,100);π Line(100,200,200,100);π Line(100,100,200,200);π SetColor(Blue);π Circle(300,200,50);ππ developgraph(rotate90); { or use (widepaper) }πend.ππ